<?php
/*
* @Descripttion: 联系人
* @Author: jiosen <4631458@qq.com>
* @Date: 2024-06-07 14:37:26
*/
namespace app\controller;

use app\BaseController;
use app\service\Bot;

class Book extends BaseController
{
    // 群列表
    public function group()
    {
        $lists = Bot::getGroupList();
        return $this->success('success',['lists'=>$lists,'total'=>count($lists)]);
    }

    // 群详情
    public function groupDetail()
    {
        $group_id = $this->request->param('group_id');

        if(empty($group_id)){
            return $this->error('缺少群号');
        }

        $detail = Bot::get('/get_group_info',['group_id'=>$group_id]);

        return json($detail);
    }

    // 群成员列表
    public function groupMember()
    {
        $group_id = $this->request->param('group_id');

        if(empty($group_id)){
            return $this->error('缺少群号');
        }

        $detail = Bot::get('/get_group_member_list',['group_id'=>$group_id,'no_cache'=>true]);

        if($detail['state'] != 1){
            return json($detail);
        }

        return $this->success('success',['lists'=>$detail['data'],'total'=>count($detail['data'])]);
        
    }

    // 好友列表
    public function friend()
    {
        $lists = Bot::getFriendList();
        return $this->success('success',['lists'=>$lists,'total'=>count($lists)]);
    }
}
